using System;
using System.ComponentModel;

using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Interactivity.InteractionRequest;
using System.Windows.Input;
using System.Windows;

namespace PrimaryModule.ViewModels
{
    public class MainViewModel : INotifyPropertyChanged, PrimaryModule.ViewModels.IMainViewModel
    {
        public MainViewModel()
        {
            // Initialize this ViewModel's commands.
            ExitCommand = new DelegateCommand<object>(AppExit, CanAppExit);
            NoticeCommand = new DelegateCommand(Notice);
            this.NotificationRequest = new InteractionRequest<Notification>();
        }

        #region ExitCommand
        public DelegateCommand<object> ExitCommand { get; private set; }

        private void AppExit(object commandArg)
        {
            Application.Current.Shutdown();
        }

        private bool CanAppExit(object commandArg)
        {
            return true;
        }
        #endregion

        #region NoticeCommand
        public InteractionRequest<Notification> NotificationRequest { get; private set; }

        public ICommand NoticeCommand { get; private set; }

        private void Notice()
        {
            this.NotificationRequest.Raise(
                new Notification { Content = "HI", Title = "HO" },
                dummy => { });
        }

        private bool CanNotice()
        {
            return true;
        }
        #endregion

        #region INotifyPropertyChanged Members
        public event PropertyChangedEventHandler PropertyChanged;

        private void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}
